package com.kedacom.freedomLabel.adapter;

import android.databinding.ViewDataBinding;
import android.graphics.Color;

import com.kedacom.freedomLabel.R;
import com.kedacom.freedomLabel.databinding.FunctionItemLayoutBinding;
import com.kedacom.freedomLabel.model.bean.Function;
import com.kedacom.lego.adapter.recyclerview.LegoBaseRecyclerViewAdapter;

import java.util.List;

/**
 * @author licheng
 * @since 2019/8/1 14:36
 */
public class FunctionAdapter extends LegoBaseRecyclerViewAdapter<Function> {

    public FunctionAdapter(List<Function> data) {
        super(R.layout.function_item_layout, data, com.kedacom.freedomLabel.BR.function);
    }

    @Override
    protected void onCustomBindItem(ViewDataBinding binding, int position) {
        FunctionItemLayoutBinding itemBinding = (FunctionItemLayoutBinding) binding;
        Function item = getData().get(position);
        itemBinding.funItemName.setBackgroundColor(Color.parseColor(item.getTextBackColor()));
        itemBinding.funItemIv.setImageResource(item.getImageRes());
        itemBinding.funItemIv.setBackgroundColor(Color.parseColor(item.getImageBackColor()));
    }
}